<% layout('/layouts/default.html', {title: '预防性维护计划管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text('预防性维护计划管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<a href="#" class="btn btn-default" id="btnRefreshTree" title="${text('刷新')}"><i class="fa fa-refresh"></i> ${text('刷新')}</a>
				<a href="#" class="btn btn-default" id="btnExpandTreeNode" title="${text('展开一级')}"><i class="fa fa-angle-double-down"></i> ${text('展开')}</a>
				<a href="#" class="btn btn-default" id="btnCollapseTreeNode" title="${text('折叠全部')}"><i class="fa fa-angle-double-up"></i> ${text('折叠')}</a>
				<% if(hasPermi('test:preventMaintainPlan:edit')){ %>
					<a href="${ctx}/test/preventMaintainPlan/form" class="btn btn-default btnTool" title="${text('新增预防性维护计划')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
				<% } %>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${preventMaintainPlan}" action="${ctx}/test/preventMaintainPlan/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">${text('计划名称')}：</label>
					<div class="control-inline">
						<#form:input path="miantianTreeName" maxlength="200" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('设备编号')}：</label>
					<div class="control-inline">
						<#form:input path="equipCode" maxlength="64" class="form-control width-120"/>
					</div>
				</div>
				<!--<div class="form-group">-->
					<!--<label class="control-label">${text('维护人员编号')}：</label>-->
					<!--<div class="control-inline">-->
						<!--<#form:input path="miantainerCode" maxlength="64" class="form-control width-120"/>-->
					<!--</div>-->
				<!--</div>-->
				<div class="form-group">
					<label class="control-label">${text('给油脂部位')}：</label>
					<div class="control-inline">
						<#form:input path="oilPart" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('给油脂方式')}：</label>
					<div class="control-inline width-120">
						<!--<#form:input path="oilWay" maxlength="1" class="form-control width-120"/>-->
						<#form:select path="oilWay" dictType="oil_way" blankOption="true"  maxlength="1" class="form-control"/>
					</div>
				</div>
				<!--<div class="form-group">-->
					<!--<label class="control-label">${text('润滑油牌号')}：</label>-->
					<!--<div class="control-inline">-->
						<!--<#form:input path="oilLabelCode" maxlength="255" class="form-control width-120"/>-->
					<!--</div>-->
				<!--</div>-->
				<!--<div class="form-group">-->
					<!--<label class="control-label">${text('补充油量')}：</label>-->
					<!--<div class="control-inline">-->
						<!--<#form:input path="supplyOilMass" maxlength="255" class="form-control width-120"/>-->
					<!--</div>-->
				<!--</div>-->
				<div class="form-group">
					<label class="control-label">${text('补充周期')}：</label>
					<div class="control-inline width-120">
						<!--<#form:input path="supplyCycle" maxlength="1" class="form-control width-120"/>-->
						<#form:select path="supplyCycle" dictType="supply_cycle" blankOption="true"  maxlength="1" class="form-control"/>
					</div>
				</div>
				<!--<div class="form-group">-->
					<!--<label class="control-label">${text('更换油量')}：</label>-->
					<!--<div class="control-inline">-->
						<!--<#form:input path="changeOilMass" maxlength="255" class="form-control width-120"/>-->
					<!--</div>-->
				<!--</div>-->
				<div class="form-group">
					<label class="control-label">${text('更换周期')}：</label>
					<div class="control-inline width-120">
						<!--<#form:input path="changeCycle" maxlength="1" class="form-control width-120"/>-->
						<#form:select path="changeCycle" dictType="change_cycle" blankOption="true"  maxlength="1" class="form-control"/>
					</div>
				</div>

				<!--<div class="form-group">-->
					<!--<label class="control-label col-sm-4" title="">-->
						<!--<span class="required hide">*</span> ${text('维护时间')}：<i class="fa icon-question hide"></i></label>-->
					<!--<div class="col-sm-8">-->
						<!--<#form:input path="maintainDate" readonly="true" maxlength="60" class="form-control Wdate" dataFormat="date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>-->
					<!--</div>-->
				<!--</div>-->
				<div class="form-group">
					<label class="control-label">${text('维护时设备运行状态')}：</label>
					<div class="control-inline width-120" style="...">
						<#form:select path="maintainRunStatus" dictType="check_run_status" blankOption="true"  maxlength="1" class="form-control"/>
					</div>
				</div>
				<!--<div class="form-group">-->
					<!--<label class="control-label">${text('状态')}：</label>-->
					<!--<div class="control-inline width-120">-->
						<!--<#form:select path="status" dictType="sys_search_status" blankOption="true" class="form-control"/>-->
					<!--</div>-->
				<!--</div>-->
				<!--<div class="form-group">-->
					<!--<label class="control-label">${text('备注信息')}：</label>-->
					<!--<div class="control-inline">-->
						<!--<#form:input path="remarks" maxlength="500" class="form-control width-120"/>-->
					<!--</div>-->
				<!--</div>-->
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text('计划名称')}', name:'miantianTreeName', index:'a.miantian_tree_name', width:250, align:"left", frozen:true, formatter: function(val, obj, row, act){
			 if(row.supplyCycle == '0'){
            	row.supplyCycle ="20天";
            }else if(row.supplyCycle == '1'){
            	row.supplyCycle ="45天";
            }else if(row.supplyCycle == '2'){
            	row.supplyCycle ="60天";
            }else{
            	row.supplyCycle ="90天";
            }

             if(row.changeCycle == '0'){
            	row.changeCycle ="1Y";
            }else if(row.changeCycle == '1'){
            	row.changeCycle ="2Y";
            }else{
            	row.changeCycle ="3Y";
            }

            if(row.oilWay == '0'){
            	row.oilWay ="手动";
            }else if(row.oilWay == '1'){
            	row.oilWay ="油枪";
            }else{
            	row.oilWay ="螺丝刀";
            }

			if(row.maintainRunStatus == '0'){
			    row.maintainRunStatus = "运行中";
            }else{
				row.maintainRunStatus = "已停止";
            }
			return '( '+row.maintainPlanCode+' ) '+'<a href="${ctx}/test/preventMaintainPlan/form?maintainPlanCode='+row.maintainPlanCode+'" class="btnList" data-title="${text('编辑预防性维护计划')}">'+(val||row.id)+'</a>';
		}},
		//{header:'${text('本级排序号')}', name:'treeSort', index:'a.tree_sort', width:150, align:"center"},
		//{header:'${text('维护节点名称')}', name:'miantianTreeName', index:'a.miantian_tree_name', width:150, align:"left"},
		{header:'${text('设备编号')}', name:'equipCode', index:'a.equip_code', width:120, align:"center"},
		//{header:'${text('维护人员编号')}', name:'miantainerCode', index:'a.miantainer_code', width:150, align:"left"},
		{header:'${text('维护部位')}', name:'oilPart', index:'a.oil_part', width:120, align:"center"},
		{header:'${text('维护方式')}', name:'oilWay', index:'a.oil_way', width:120, align:"center"},
		{header:'${text('备品备件编号')}', name:'oilLabelCode', index:'a.oil_label_code', width:120, align:"center"},
		//{header:'${text('补充油量')}', name:'supplyOilMass', index:'a.supply_oil_mass', width:120, align:"left"},
		{header:'${text('补充周期')}', name:'supplyCycle', index:'a.supply_cycle', width:120, align:"center"},
		//{header:'${text('更换油量')}', name:'changeOilMass', index:'a.change_oil_mass', width:150, align:"left"},
		{header:'${text('更换周期')}', name:'changeCycle', index:'a.change_cycle', width:120, align:"center"},
		//{header:'${text('维护时间')}', name:'maintainDate', index:'a.maintain_date', width:120, align:"center"},
		{header:'${text('运行状态')}', name:'maintainRunStatus', index:'a.maintain_run_status', width:120, align:"center"},
		<!--{header:'${text('状态')}', name:'status', index:'a.status', width:150, align:"center", formatter: function(val, obj, row, act){-->
			<!--return js.getDictLabel(${@DictUtils.getDictListJson('sys_search_status')}, val, '${text('未知')}', true);-->
		<!--}},-->
		//{header:'${text('创建时间')}', name:'createDate', index:'a.create_date', width:150, align:"center"},
		{header:'${text('备注信息')}', name:'remarks', index:'a.remarks', width:120, align:"left"},
		{header:'${text('操作')}', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('test:preventMaintainPlan:edit')){ %>
				actions.push('<a href="${ctx}/test/preventMaintainPlan/form?maintainPlanCode='+row.maintainPlanCode+'" class="btnList" title="${text('编辑预防性维护计划')}"><i class="fa fa-pencil"></i></a>&nbsp;');
				<!--if (row.status == Global.STATUS_NORMAL){-->
					<!--actions.push('<a href="${ctx}/test/preventMaintainPlan/disable?maintainPlanCode='+row.maintainPlanCode+'" class="btnList" title="${text('停用预防性维护计划')}" data-confirm="${text('确认要停用该预防性维护计划吗？')}"><i class="glyphicon glyphicon-ban-circle"></i></a>&nbsp;');-->
				<!--}-->
				<!--if (row.status == Global.STATUS_DISABLE){-->
					<!--actions.push('<a href="${ctx}/test/preventMaintainPlan/enable?maintainPlanCode='+row.maintainPlanCode+'" class="btnList" title="${text('启用预防性维护计划')}" data-confirm="${text('确认要启用该预防性维护计划吗？')}"><i class="glyphicon glyphicon-ok-circle"></i></a>&nbsp;');-->
				<!--}-->
				actions.push('<a href="${ctx}/test/preventMaintainPlan/delete?maintainPlanCode='+row.maintainPlanCode+'" class="btnList" title="${text('删除预防性维护计划')}" data-confirm="${text('确认要删除该预防性维护计划及所有子预防性维护计划吗？')}" data-deltreenode="'+row.id+'"><i class="fa fa-trash-o"></i></a>&nbsp;');
				actions.push('<a href="${ctx}/test/preventMaintainPlan/form?parentCode='+row.id+'" class="btnList" title="${text('新增下级预防性维护计划')}"><i class="fa fa-plus-square"></i></a>&nbsp;');
			<% } %>
			<!--<预防性维护计划安排权限归设备管理所有>-->
			 <% if(hasPermi('test:preventMaintainPlan:assign')){ %>
                actions.push('<a href="${ctx}/test/preventMaintianSchedule/form?maintainPlanCode='+row.maintainPlanCode+'" class="btnList" title="${text('预防性维护计划安排')}"><i class="fa fa-arrow-circle-right"></i></a>&nbsp;');
             <% } %>
			<!--<维护结果录入权限与维护计划编辑权限是相互独立的，维护结果录入权归维护员，计划编辑权归设备管理员>-->
			 <% if(hasPermi('test:preventMaintainResult:edit')){ %>
                actions.push('<a href="${ctx}/test/preventMaintainResult/form?maintainPlanCode='+row.maintainPlanCode+'" class="btnList" title="${text('维护结果录入')}"><i class="fa fa-magic"></i></a>&nbsp;');
             <% } %>
			return actions.join('');
		}}
	],
	treeGrid: true,			// 启用树结构表格
	defaultExpandLevel: 0,	// 默认展开的层次
	expandNodeClearPostData: 'miantianTreeName,equipCode,miantainerCode,oilPart,oilWay,oilLabelCode,supplyOilMass,supplyCycle,changeOilMass,changeCycle,maintainDate,maintainRunStatus,status,remarks,', // 展开节点清理请求参数数据（一般设置查询条件的字段属性，否则在查询后，不能展开子节点数据）	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>